package proxy.login
{
    import com.zn.multilanguage.MultilanguageManager;
    import com.zn.net.HttpRequest;
    
    import controller.init.LoaderResCommand;
    
    import flash.events.Event;
    
    import mediator.createRole.CreateRoleCompMediator;
    import mediator.login.LoginMediator;
    import mediator.prompt.PromptMediator;
    
    import org.puremvc.as3.interfaces.IProxy;
    import org.puremvc.as3.patterns.proxy.Proxy;

    /**
     *登录
     * @author zn
     *
     */
    public class LoginProxy extends Proxy implements IProxy
    {
        public static const NAME:String = "LoginProxy";

		/**
		 * 成功
		 */
        public static const SUCCESS_NOTE:String = "LoginProxy.Success";

		/**
		 *失败 
		 */        
        public static const FAILURE_NOTE:String = "LoginProxy.failure";

        public function LoginProxy(data:Object = null)
        {
            super(NAME, data);
        }

        /**
         *登录
         *
         */
        public function login(userName:String, password:String):void
        {
			sendNotification(PromptMediator.SHOW_ALERT_NOTE,MultilanguageManager.getString("loginFail"));
			return ;
            var params:String =
                "userName=" + userName +
                "&password=" + password;

//            var httpRequest:HttpRequest = new HttpRequest("Default.aspx", params, false,false,true, loginResult);
//            httpRequest.load();
			loginResult(null);
        }

        /**
         *登录返回
         *
         */
        private function loginResult(body:XML):void
        {
            sendNotification(SUCCESS_NOTE);
            sendNotification(LoginMediator.DESTROY_NOTE);

            //加载进入游戏的资源
            sendNotification(LoaderResCommand.LOAD_RES_NOTE);
			
			//sendNotification(CreateRoleCompMediator.SHOW_NOTE);
			
        }
    }
}